﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI;
using GrayParrot.Web.Helpers;

namespace GrayParrot.Web.UI
{
    public class Page : System.Web.UI.Page
    {
        public string InnerHtml { get; internal set; }

        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            StringBuilder sb = new StringBuilder();

            HtmlTextWriter tw = new HtmlTextWriter(new StringWriter(sb));
            base.Render(tw);

            InnerHtml = sb.ToString();

            List<Bootstrapminator> objs = this.GetAllControlsOfType<Bootstrapminator>().ToList();

            if (objs.Count() > 0)
            {
                Bootstrapminator m_control = (Bootstrapminator)objs[0];

                if (m_control.UseBootstrap)
                {
                    InnerHtml = m_control.Decorate(InnerHtml);
                }
            }

            writer.Write(InnerHtml);
            //base.Render(writer);
        }
    }
}
